#include <stdio.h>
#include "list.h"

typedef struct stu_node
{
    int age;
    char name[64];
    struct list_head list;
}stu;

int main(int argc, char const *argv[])
{
    //定义一个头结点
    struct list_head head;

    //初始化头结点
    INIT_LIST_HEAD(&head);

    //头插
    stu d1 = {20,"zhangsan"};
    stu d2 = {30,"lisan"};

    list_add(&d1.list, &head);
    list_add(&d2.list, &head);

    //遍历
    stu *tmp;
    struct list_head *pos;
    list_for_each(pos, &head)
    {
        tmp = list_entry(pos, stu, list);
        printf("%d %s\n",tmp->age,tmp->name);
    }
}
